package com.kalvin.kvf.modules.xhs.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kalvin.kvf.common.utils.ShiroKit;
import com.kalvin.kvf.modules.sys.entity.User;
import org.springframework.stereotype.Service;
import com.kalvin.kvf.modules.xhs.entity.XhsVideo;
import com.kalvin.kvf.modules.xhs.mapper.XhsVideoMapper;

import java.util.List;

/**
 * <p>
 * 视频库表 服务实现类
 * </p>
 * @since 2023-12-01 11:32:07
 */
@Service
public class XhsVideoServiceImpl extends ServiceImpl<XhsVideoMapper, XhsVideo> implements XhsVideoService {

    @Override
    public Page<XhsVideo> listVideoPage(XhsVideo video) {
        User user = ShiroKit.getUser();
        if(!user.getUsername().equals("admin")){
            video.setPhone(user.getPhone());
        }
        Page<XhsVideo> page = new Page<>(video.getCurrent(), video.getSize());
        List<XhsVideo> videos = baseMapper.selectVideoList(video, page);
        return page.setRecords(videos);
    }

}
